package com.xiyu.service.controller.admin.files;
import com.xiyu.service.vo.files.housingAgreement.HousingAgreementSingleGetOutput;
import com.xiyu.service.vo.files.housingAgreement.HousingAgreementUpdateInput;
import com.xiyu.service.vo.files.housingAgreement.HousingAgreementCreateInput;
import com.xiyu.service.vo.files.housingAgreement.HousingAgreementPageQueryOutput;
import com.xiyu.service.vo.files.housingAgreement.HousingAgreementPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.files.HousingAgreementService;

@Tag(name = "用房协议")
@RestController
@RequestMapping("/files/housing-agreement")
@Validated
public class HousingAgreementController {

    @Resource
    private HousingAgreementService housingAgreementService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询用房协议")
    @PreAuthorize("@ss.hasPermission('files:housingAgreement:query')")
    public CommonResult<PageResult<HousingAgreementPageQueryOutput>> pageQuery(@Valid HousingAgreementPageQueryInput inputVO) {
        return success(housingAgreementService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增用房协议")
    @PreAuthorize("@ss.hasPermission('files:housingAgreement:create')")
    public CommonResult<Long> create(@Valid @RequestBody HousingAgreementCreateInput inputVO) {
        return success(housingAgreementService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新用房协议")
    @PreAuthorize("@ss.hasPermission('files:housingAgreement:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody HousingAgreementUpdateInput inputVO) {
        return success(housingAgreementService.update(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个用房协议")
    @Parameter(name = "id", description = "用房协议主键ID", example = "")
    public CommonResult<HousingAgreementSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(housingAgreementService.singleGet(id));
    }

}
